package com.manjason.property.task;

import com.manjason.property.Property;
import com.manjason.property.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class PlayerHealthTask implements Runnable {
    @Override
    public void run() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            com.manjason.property.entity.Property theProperty = Util.getPropertyByPlayerName(player.getName());
            if (theProperty != null) {
                double health = (theProperty.getPhysique() * 5) + 20;
                if (player.getMaxHealth() != health) Bukkit.getScheduler().scheduleSyncDelayedTask(Property.getInstance(), ()->player.setMaxHealth(health));
            }
        }
    }
}
